import { numKeep2decimal } from "@/utils";
import { memo } from "react";

import style from './index.module.scss';

interface IProps {
    /**
     * 总额
     */
    total?: number;
    /**
     * 当前已拆分
     */
    current?: number;
}

/**
 * 拆分价值规划指标差额显示
 */
const DiffSaleExpect = memo((props: IProps) => {
    const {total = 0, current = 0} = props;
    const diff = total - current;
    return (<span className={style.diff}>
        {
            diff > 0 && (
                `销售指标剩余拆分金额：${numKeep2decimal(diff)}元`
            )
        }
        {
            diff < 0 && (
                `销售指标拆分金额已超出：${numKeep2decimal(-diff)}元`
            )
        }
    </span>);
});

export {
    DiffSaleExpect
};

